home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / pdcurs21 / portable / raw.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-18  |  2.6 KB  |  94 lines

  1. #define CURSES_LIBRARY    1
  2. #include <curses.h>
  3.  
  4. #ifdef UNIX
  5. #define NOTLIB
  6. #include <defs.h>
  7. #include <term.h>
  8. #endif
  9. #undef  raw
  10.  
  11. #ifdef PDCDEBUG
  12. char *rcsid_raw = "$Header: C:\CURSES\portable\RCS\raw.c 2.1 1993/06/18 20:20:49 MH Rel MH $";
  13. #endif
  14.  
  15.  
  16.  
  17.  
  18. /*man-start*********************************************************************
  19.  
  20.   raw()    - enable raw mode
  21.  
  22.   X/Open Description:
  23.         The terminal in placed into or out of raw mode.  Raw mode is
  24.         similar to cbreak mode, in that characters typed are immediately
  25.         passed through to the user program.  The differences are that in
  26.         raw mode, the INTR, QUIT, SUSP, and STOP characters are passed
  27.         through without being interpreted, and without generating a
  28.         signal.  The behaviour of the BREAK key depends on other
  29.         parameters of the terminal drive that are not set by curses.
  30.  
  31.   PDCurses Description:
  32.         Raw mode in the traditional sense refers to input handling.
  33.         Contrast raw_output() which enables 8bit characters.
  34.  
  35.         FYI:    PDCurses does NOT provide signal(3) support,
  36.          this must be done by the application.
  37.  
  38.   X/Open Return Value:
  39.         This function returns OK on success and ERR on error.
  40.  
  41.   X/Open Errors:
  42.         No errors are defined for this function.
  43.  
  44.   Portability:
  45.         PDCurses        int raw( void );
  46.         X/Open Dec '88  int raw( void );
  47.         BSD Curses      int raw( void );
  48.         SYS V Curses    int raw( void );
  49.  
  50. **man-end**********************************************************************/
  51.  
  52. int     raw(void)
  53. {
  54. #ifdef OS2
  55.     KBDINFO KbdInfo;
  56. #endif
  57.  
  58. #ifdef PDCDEBUG
  59.     if (trace_on) PDC_debug("raw() - called\n");
  60. #endif
  61.  
  62. #ifdef OS2
  63.     KbdGetStatus(&KbdInfo,0);
  64.     KbdInfo.fsMask |= KEYBOARD_BINARY_MODE;
  65.     KbdInfo.fsMask &= ~KEYBOARD_ASCII_MODE;
  66.     KbdSetStatus(&KbdInfo,0);
  67. #endif
  68.  
  69. #ifdef UNIX
  70. #ifdef USE_TERMIO
  71. #if 0
  72.     _CUR_TERM.prog_mode.c_lflag &= ~(ICANON|ISIG);
  73.     _CUR_TERM.prog_mode.c_iflag &= ~(INPCK|ISTRIP|IXON);
  74.     _CUR_TERM.prog_mode.c_oflag &= ~(OPOST);
  75.     _CUR_TERM.prog_mode.c_cc[VMIN] = 1;
  76.     _CUR_TERM.prog_mode.c_cc[VTIME] = 0;
  77.     ioctl(_CUR_TERM.fd, TCSETAW, &_CUR_TERM.prog_mode);
  78. #endif
  79.     _CUR_TERM.prog_mode.c_lflag &= ~(ICANON|ISIG);
  80.     _CUR_TERM.prog_mode.c_iflag &= ~(IXON);
  81.     _CUR_TERM.prog_mode.c_iflag |= ICRNL;
  82.     ioctl(_CUR_TERM.fd, TCSETAW, &_CUR_TERM.prog_mode);
  83. #else
  84.     _CUR_TERM.prog_mode.sg_flags |= RAW;
  85.     ioctl(_CUR_TERM.fd, TIOCSETP, &_CUR_TERM.prog_mode);
  86. #endif
  87. #endif
  88.  
  89.     _cursvar.raw_inp = TRUE;
  90.     PDC_set_ctrl_break(FALSE);      /* disallow ^BREAK on disk I/O */
  91. /*    flushinp(); */
  92.     return( OK );
  93. }
  94.